﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SalePartial.IDAL;
using System.Data;
using System.Data.SqlClient;
using SalePartial.Model;

namespace SalePartial.BLL
{
    public class XPDeliveryAddres : IXPDeliveryAddres
    {
        private IXPDeliveryAddres dal = SalePartial.DALFactory.DataAccess.CreateXPDeliveryAddres();

        public  XPDeliveryAddresInfo GetXPDeliveryAddres(Guid id)
        {
            SqlDataReader reader = this.SelectReader(id);
            XPDeliveryAddresInfo info = null;
            if (reader.Read())
            {
                info = new XPDeliveryAddresInfo(reader);
                if (!reader.IsClosed)
                {
                    reader.Close();
                }
            }
            return info;

        }

        public int Delete(Guid AddressID)
        {
            return dal.Delete(AddressID);

        }

        public int DeleteByCompanyID(Guid CompanyID)
        {
            return dal.DeleteByCompanyID(CompanyID);
        }

        public int DeleteDynamic(string v_whereCondition)
        {
            return dal.DeleteDynamic(v_whereCondition);
        }

        public int Insert(Guid AddressID, Guid CompanyID, String Contact, String Street, String City, String Province,
             String Country, String Postcode, String Phone, String CellPhone, Boolean IsDefault, DateTime CreateDate) 
        {
            XPDeliveryAddresInfo info = new XPDeliveryAddresInfo();
            info.AddressID = AddressID;
            info.CompanyID = CompanyID;
            info.Contact = Contact;
            info.Street = Street;
            info.City = City;
            info.Province = Province;
            info.Country = Country;
            info.Postcode = Postcode;
            info.Phone = Phone;
            info.CellPhone = CellPhone;
            info.IsDefault = IsDefault;
            info.CreateDate = CreateDate;

            return dal.Insert(info);
        }

        public int Insert(XPDeliveryAddresInfo info)
        {
            return dal.Insert(info);
        }

        public DataSet SelectAll()
        {
            return dal.SelectAll();
        }

        public DataSet SelectDynamic(string v_whereCondition, string v_orderByExpression)
        {
            return dal.SelectDynamic(v_whereCondition, v_orderByExpression);
        }

        public DataSet SelectPaged()
        {
            return dal.SelectPaged();
        }

        public SqlDataReader SelectReader(Guid AddressID)
        {
            return dal.SelectReader(AddressID);
        }

        public SqlDataReader SelectReaderByCompanyID(Guid CompanyID)
        {
            return dal.SelectReaderByCompanyID(CompanyID);
        }

        public DataSet SelectByCompanyID(Guid CompanyID)
        {
            return dal.SelectByCompanyID(CompanyID);
        }

        public DataSet SelectSingle(Guid AddressID)
        {
            return dal.SelectSingle(AddressID);
        }

        public int Update(XPDeliveryAddresInfo info)
        {
            return dal.Update(info);
        }

    }
}
